using System;
using System.Xml;
using System.Xml.Serialization;

namespace ProcessesSMS
{
	/// <summary>
	/// Summary description for XMLLoader.
	/// </summary>
	public class XMLLoader
	{
		public XMLLoader()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		public System.Collections.ArrayList XMLLoader1(string filename)
		{
			System.Collections.ArrayList res = new System.Collections.ArrayList();
			
			XmlTextReader reader = new XmlTextReader(filename);
			while (reader.Read())
			{
				if (reader.NodeType == XmlNodeType.Element)
				{
					if (reader.LocalName.Equals("Item"))
					{
						res.Add(reader.GetAttribute("ID"));
						res.Add(reader.GetAttribute("value"));
					}
				}
			}
			reader.Close();
			return res;
		}
		public void XMLWriter1(string filename, string [] data)
		{
			XmlTextWriter writer = new XmlTextWriter(filename,null);
			try
			{
				writer.Formatting = Formatting.Indented;
				writer.Indentation= 6;
				writer.Namespaces = false;
				writer.WriteStartDocument();
				writer.WriteStartElement("","Content","");
				for (int i=0; i < data.Length;i++)
				{
					writer.WriteStartElement("","Item","");
					writer.WriteStartAttribute("","ID","");
					writer.WriteString(i.ToString());
					writer.WriteEndAttribute();
					writer.WriteStartAttribute("","value","");
					writer.WriteString(data[i]);
					writer.WriteEndAttribute();
					
					writer.WriteEndElement();
					

				}
				writer.WriteEndElement();
				writer.WriteEndDocument();
				writer.Flush();
				
			}
			catch
			{
			}
			finally
			{
				writer.Close();
			}

		}
	}
}
